package com.vcms.controller.customer.states;

import com.vcms.controller.customer.TransactionController;
import com.vcms.controller.system.MainController;
import com.vcms.view.simulation.customer.CustomerPanel;
import com.vcms.view.simulation.system.SimulatorControlPanel;

public class InitialState extends TransactionState {
	
	public InitialState(TransactionController transactionController){
		setTransactionController(transactionController);
		
	}
	
	@Override
	public boolean handleDisplayCustomerPanel() {
		System.out.println("Inside Initialize State Handle - Setup Customer Panel");
		
		TransactionController transactionController = getTransactionController();
		MainController mainController = transactionController.getMainControler();
		SimulatorControlPanel scp = mainController.getSimulatorControlPanel();
		
		CustomerPanel customerPanel = transactionController.getCustomerPanel();
		
		if (customerPanel == null) {
			
			customerPanel = new CustomerPanel(scp, transactionController, transactionController.getMode());
		}
		
		customerPanel.display();
		transactionController.setCustomerPanel(customerPanel);

		// Transit to READY state
		transactionController.transitState(StateFactory.getInstance().create(TransactionState.READY, transactionController));
		
		return true;
	}
	
	@Override
	public boolean handleStartTransaction() {
		System.out.println("[InitialState] - Incorrect state to handle start transaction!");
		
		return false;
	}
	
	@Override
	public boolean handleProcessMoneyReceived() {
		System.out.println("[InitialState] - Incorrect state to handle process money received!");
		
		return false;
	}
	
	@Override
	public boolean handleCompleteTransaction() {
		System.out.println("[InitialState] - Incorrect state to complete transaction!");
		
		return false;
	}
	
	@Override
	public boolean handleTerminateTransaction() {
		System.out.println("[InitialState] - Incorrect state to terminate transaction!");
		
		return false;
	}
	
	@Override
	public boolean handleTerminateFault() {
		System.out.println("[InitialState] - Incorrect state to handle terminate fault!");
		
		return false;
	}
	
	@Override
	public boolean handleRefreshCustomerPanel() {
		System.out.println("[InitialState] - Incorrect state to handle refresh customer panel!");
		
		return false;
	}
	
	public void printState(){
		System.out.println("- Initialize State -");
	}
}
